package trading.algo.BearTask;

import java.util.ArrayList;
import java.util.List;
import java.util.TimerTask;

import trading.bo.IBAccessorBO;
import trading.util.Constants;

public class VIXFuturePriceTask extends TimerTask {
	private static List<Double> VIXFuturePriceList = null;
	// Store in timer order, this way gurentees front month gets stored first.
	
	public static void storeVIXFuturePrice(double price) {
		// Init
		if (VIXFuturePriceList == null) {
			VIXFuturePriceList = new ArrayList<Double>();
		}
		
		// Store temporarily
		VIXFuturePriceList.add(price);
	}
	
	public static List<Double> getVIXFuturePriceList() {
		return VIXFuturePriceList;
	}
	
	public static void resetVIXFuturePriceList() {
		VIXFuturePriceList = null;
	}
	
	private IBAccessorBO ibAccessorBO;
	private String expiration;
	
	public VIXFuturePriceTask(IBAccessorBO ibAccessorBO, String expiration) {
		this.ibAccessorBO = ibAccessorBO;
		this.expiration = expiration;
	}

	@Override
	public void run() {
		this.ibAccessorBO.reqLastCloseFuturePrice(Constants.VIX, expiration);
	}
	
	public static int secondsNeeded() {
	    return 3;
	}

}
